<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.2.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"singingxy.github.io","root":"/","images":"/images","scheme":"Gemini","version":"8.6.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="VS Code 默认是使用 UTF-8 格式来打开文件的，如果遇到 GBK 或者 gb2312 格式的文件，里面的中文就会变成乱码。一般情况下可以点击下方的UTF-8按钮来做转换，点击后会出现“通过编码重新打开”和“通过编码保存”两个选项，选择相应的编码转换就可以了。 但是如果经常接触到 gbk 或 gb2312 格式的文件，上面的方法未免显得太麻烦，最好是让编辑器应用文件本身的编码来打开文件。">
<meta property="og:type" content="article">
<meta property="og:title" content="如何让VS Code按照文件原本编码打开文件">
<meta property="og:url" content="https://singingxy.github.io/2019/VS-Code-encoding/index.html">
<meta property="og:site_name" content="sing&#39;s blog">
<meta property="og:description" content="VS Code 默认是使用 UTF-8 格式来打开文件的，如果遇到 GBK 或者 gb2312 格式的文件，里面的中文就会变成乱码。一般情况下可以点击下方的UTF-8按钮来做转换，点击后会出现“通过编码重新打开”和“通过编码保存”两个选项，选择相应的编码转换就可以了。 但是如果经常接触到 gbk 或 gb2312 格式的文件，上面的方法未免显得太麻烦，最好是让编辑器应用文件本身的编码来打开文件。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://singingxy.github.io/2019/VS-Code-encoding/1.png">
<meta property="article:published_time" content="2019-11-30T05:23:25.000Z">
<meta property="article:modified_time" content="2019-11-30T05:23:25.000Z">
<meta property="article:author" content="Sing">
<meta property="article:tag" content="VS Code">
<meta property="article:tag" content="编码">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://singingxy.github.io/2019/VS-Code-encoding/1.png">


<link rel="canonical" href="https://singingxy.github.io/2019/VS-Code-encoding/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://singingxy.github.io/2019/VS-Code-encoding/","path":"/2019/VS-Code-encoding/","title":"如何让VS Code按照文件原本编码打开文件"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>如何让VS Code按照文件原本编码打开文件 | sing's blog</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">sing's blog</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">C'est La Vie Mon Ami.</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>







</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-overview-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Sing</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">18</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">2</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



          </div>
        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://singingxy.github.io/2019/VS-Code-encoding/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Sing">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="sing's blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          如何让VS Code按照文件原本编码打开文件
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2019-11-30 13:23:25" itemprop="dateCreated datePublished" datetime="2019-11-30T13:23:25+08:00">2019-11-30</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B0%8F%E9%97%AE%E9%A2%98/" itemprop="url" rel="index"><span itemprop="name">小问题</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p>VS Code 默认是使用 UTF-8 格式来打开文件的，如果遇到 GBK 或者 gb2312 格式的文件，里面的中文就会变成乱码。一般情况下可以点击下方的<code>UTF-8</code>按钮来做转换，点击后会出现“通过编码重新打开”和“通过编码保存”两个选项，选择相应的编码转换就可以了。</p>
<p>但是如果经常接触到 gbk 或 gb2312 格式的文件，上面的方法未免显得太麻烦，最好是让编辑器应用文件本身的编码来打开文件。</p>
<span id="more"></span>

<p>可以依次点<code>文件</code>–<code>首选项</code>–<code>设置</code>来打开设置，然后找到<code>文本编辑器</code>-<code>文件</code><br><img src="/2019/VS-Code-encoding/1.png"><br>把 Auto Guess Encoding 这一项的勾选上。<br>如果觉得在界面里寻找比较麻烦也可以直接在设置的搜索框里输入<code>AutoGuessEncoding</code>,也可以找到这一项设置。<br>可以看到这一项的功能是打开文件时猜测字符编码，有一定失败的可能。</p>
<p>设置完以后在遇到 gbk 格式的文件就方便多啦。</p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/VS-Code/" rel="tag"># VS Code</a>
              <a href="/tags/%E7%BC%96%E7%A0%81/" rel="tag"># 编码</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2019/hexo-themes-push/" rel="prev" title="hexo主题文件不能push">
                  <i class="fa fa-chevron-left"></i> hexo主题文件不能push
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2019/srcset-size/" rel="next" title="img标签里的srcset和sizes是什么">
                  img标签里的srcset和sizes是什么 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sing</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>

  




  





</body>
</html>
